<?php
  class basic_config extends admin{
    function make_extra($buff,&$buff){

      if(isset($_POST['edit'])){
	foreach($_POST as $name => $value){
	  if($this->is_value($name)){
	    $this->set_core_value($name, $value);
	  }
	}
      }

      if(kleocore::get_core_value('allow_registration') == 'no'){
	$notallowreg = 'selected';
      }
      if(kleocore::get_core_value('email_confirmation') == 'no'){
	$notsendconf = 'selected';
      }
      $items = array(
		array(
		  "id" => "web_title",
		  "label" => L_WEB_TITLE,
		  "name" => "web_title",
		  "value" => kleocore::get_core_value('web_title')
		),
		array(
		  "id" => "web_name",
		  "label" => L_WEB_NAME,
		  "name" => "web_name",
		  "value" => kleocore::get_core_value('web_name')
		),
		array(
		  "id" => "web_slogan",
		  "label" => L_WEB_SLOGAN,
		  "name" => "web_slogan",
		  "value" => kleocore::get_core_value('web_slogan')
		),
		array(
		  "id" => "admin_name",
		  "label" => L_ADMIN_NAME,
		  "name" => "admin_name",
		  "value" => kleocore::get_core_value('admin_name')
		),
		array(
		  "id" => "admin_email",
		  "label" => L_ADMIN_EMAIL,
		  "name" => "admin_email",
		  "value" => kleocore::get_core_value('admin_email')
		),
		array(
		  "id" => "allow_registration",
		  "label" => L_ALLOW_REGISTRATION,
		  "custom_content" => '<select name="allow_registration" class="big-form-title"><option value="yes">'.L_YES.'</option><option value="no" '.$notallowreg.'>'.L_NO.'</option></select>'
		),
		array(
		  "id" => "allow_registration",
		  "label" => L_EMAIL_CONFIRMATION_FOR_NEW_USERS,
		  "custom_content" => '<select name="email_confirmation" class="big-form-title"><option value="yes">'.L_YES.'</option><option value="no" '.$notsendconf.'>'.L_NO.'</option></select>'
		),
		array(
		  "id" => "web_lang",
		  "label" => L_LANGUAGE,
		  "custom_content" => $this->get_langs_select()
		),
		array(
		  "id" => "web_style",
		  "label" => L_TEMPLATE_STYLE,
		  "custom_content" => $this->get_styles_select()
		)
      );
      $form_buff;
      $jumper_menu;
      foreach($items as $item){
	if(!$item['custom_content']){
	  $form_buff .= '<div class="description-form" id="'.$item['id'].'">
	    '.$item['label'].'
	    <input name="'.$item['name'].'" value="'.$item['value'].'" type="text" class="big-form-title"  />
	  </div>';
	} else {
	  $form_buff .= '<div class="description-form" id="'.$item['id'].'">
	    '.$item['label']."\n".$item['custom_content'].'
	  </div>';
	}
	$jumper_menu .= '<li onclick="new Effect.ScrollTo(\''.$item['id'].'\');">'.$item['label'].'</li>';
      }
      $this->tpl_set(array(
	      "BASIC_CONFIG_FORM" => $form_buff,
	      "JUMPER_MENU" => $jumper_menu
	      ),
	      false, $buff,$buff);
    }

    function get_langs_select(){
      $buff = '<select class="big-form-title" name="web_lang">';
	if ($dir = opendir(KLEO_LANG_DIR)) {
         while (($file = readdir($dir)) !== false) { 
	  if($file !== '.' && $file !== '..'){
	    if(file_exists(KLEO_LANG_DIR.$file.'/main.php')){
	      if(kleocore::get_core_value('web_lang') == $file){
		$selected = ' selected';
	      }
	      $languages = parse_ini_file(KLEO_LANG_DIR.'locale.ini');
	      $buff .= '<option value="'.$file.'"'.$selected.'>'.$languages['code_'.$file].'</option>';
	      unset($selected);
	    }
	  }
	 }
	}
      $buff .= '</select>';
      return $buff;
    }
    function get_styles_select(){
      $buff = '<select class="big-form-title" name="web_style">';
      $styles_dir = opendir(KLEO_TEMPLATE_DIR.KLEO_CURRENT_TEMPLATE.'/styles');
      while(false !== ($style = readdir($styles_dir))){
	if($style !== '.' && $style !== '..' && is_dir(KLEO_TEMPLATE_DIR.KLEO_CURRENT_TEMPLATE.'/styles/'.$style)){
	  if(kleocore::get_core_value('web_lang') == $style){
	    $selected = ' selected';
	  }
	  $buff .= '<option value="'.$style.'"'.$selected.'>'.$style.'</option>';
	}
      }
      $buff .= '</select>';
      return $buff;
    }
  }
?>
